﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AAA.Meta.Chart.Data;

namespace AAA.Chart.Component
{
    public partial class ProfileChartBase : UserControl
    {
        protected ProfileMgr _ProfileMgr = new ProfileMgr();
        protected List<float> _lstCellPrice = new List<float>();
        protected Color BoxColor = Color.Black;
        protected Color StartPeriodBoxColor = Color.Red;
        protected Color AxisColor = Color.Black;
        protected Color AxisLineColor = Color.Black;
        protected Color GridColor = Color.YellowGreen;
        protected Color HighlightColor = Color.Tomato;
        protected float fBoxHeight = 14;
        protected float fBoxWidth = 14;
        protected float fScale = 1;
        protected float fAxisXAreaHeight;
        protected float fYStartIndex = 0;
        protected float fYEndIndex = 0;
        protected int _iPriceCount = 0;
        protected Color[] _cStackColors = { Color.Red, Color.FromArgb(170, 255, 0, 0), Color.FromArgb(100, 255, 0, 0),
                                            Color.Orange, Color.FromArgb(170, 255, 165, 0), Color.FromArgb(100, 255, 165, 0),
                                            Color.Yellow, Color.FromArgb(170, 255, 255, 0), Color.FromArgb(100, 255, 255, 0),
                                            Color.Green, Color.FromArgb(120, 0, 128, 0), Color.FromArgb(60, 0, 128, 0),
                                            Color.Blue, Color.FromArgb(170, 0, 0, 255), Color.FromArgb(100, 0, 0, 255),
                                            Color.Cyan, Color.FromArgb(100, 0, 255, 255), Color.FromArgb(50, 0, 255, 255),
                                            Color.Purple, Color.FromArgb(170, 128, 0, 128), Color.FromArgb(100, 128, 0, 128) };
        protected Font _ChartFont = new Font("細明體", 10);

        public ProfileChartBase()
        {
            InitializeComponent();
            SetCrossLineVisible(false);
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            PaintChart();
        }

        public virtual void PaintChart() {
            
        }

        public int PriceCount
        {
            get { return _iPriceCount; }
        }

        public float BoxHeight
        {
            get { return fBoxHeight; }
            set { fBoxHeight = value; }
        }

        public float BoxWidth
        {
            get { return fBoxWidth; }
            set { fBoxWidth = value; }
        }

        public float YStartIndex
        {
            get { return fYStartIndex; }
            set { fYStartIndex = value; }
        }

        public float YEndIndex
        {
            get { return fYEndIndex; }
            set { fYEndIndex = value; }
        }

        public virtual void AddProfileMgr(ProfileMgr pmProfileMgr) { 
        }

        public void MoveCrossLine(int X, int Y, int ShowType) {
            chartCrossV.Visible = false;
            chartCrossH.Visible = false;
            chartCrossV.Width = Width;
            chartCrossH.Height = Height;
            chartCrossV.Left = 0;
            chartCrossV.Top = Y;
            chartCrossH.Left = X;
            chartCrossH.Top = 0;
            chartCrossV.Visible = true;
            if (ShowType == 1)
            {
                chartCrossH.Visible = true;
            }
        }

        public void SetCrossLineVisible(bool blVisible) {
            chartCrossH.Visible = blVisible;
            chartCrossV.Visible = blVisible;
        }
    }
}
